//
//  IGUpPhotoVC.m
//  jingdongfang
//
//  Created by MTiMac02 on 2018/1/26.
//  Copyright © 2018年 LJL. All rights reserved.
//

#import "IGUpPhotoVC.h"

@interface IGUpPhotoVC ()

@end

@implementation IGUpPhotoVC
#pragma mark -生命周期
- (void)viewDidLoad {
    [super viewDidLoad];
    
    UIScrollView *myScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, KSCREENWIDTH, KSCREENHEIGHT)];
    myScrollView.backgroundColor = [UIColor blackColor];
    myScrollView.pagingEnabled = YES;
    myScrollView.bounces = NO;
    myScrollView.scrollEnabled=YES;
    myScrollView.showsHorizontalScrollIndicator = NO;
    myScrollView.showsVerticalScrollIndicator = NO;
    myScrollView.alwaysBounceVertical = NO;
    myScrollView.alwaysBounceHorizontal = NO;
    
    [self.view addSubview:myScrollView];
    //根据tag 来获取当前点击的图片
    myScrollView.contentOffset = CGPointMake(KSCREENWIDTH * (self.imageTag-1001), 10);
    myScrollView.contentSize = CGSizeMake(KSCREENWIDTH * self.photoArr.count, 0);
    //创建
    for (int i = 0; i < self.photoArr.count; i++)
    {
        UIImageView *img = [[UIImageView alloc] initWithFrame:CGRectMake(self.view.frame.size.width * i + 10, 0, self.view.frame.size.width - 20, self.view.frame.size.height)];
        [img sd_setImageWithURL:self.photoArr[i]];
        
        [myScrollView addSubview:img];
        
        //自适应图片大小
        img.contentMode = UIViewContentModeScaleAspectFit;
        
    }
    
    //轻拍跳出照片浏览
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction)];
    
    [myScrollView addGestureRecognizer:tap];
    
}

- (void)tapAction
{
    [self dismissViewControllerAnimated:YES completion:^{

    }];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
